﻿@{
    ViewBag.Title = "ObjectCreate";
    Layout = "~/Views/Shared/_Page.cshtml";
}

<script type="text/javascript">
    
    window.onload = function() {
        /*
            literal object
         */

        var book = {
            "title": "Javascript Definitive Guide",
            "publish date": "2009-05-08",
            author: {
                firstname: "David",
                lastname: "Flanagan"
            }
        };

        ZEUS.DEBUG.log("1. ** literal object **");
        ZEUS.DEBUG.log("Title: " + book.title);
        ZEUS.DEBUG.log("Author: " + book.author.firstname + " " + book.author.lastname);
        ZEUS.DEBUG.log("Publish Date: " + book["publish date"]);

        ZEUS.DEBUG.log("<br />");

        /*
            Use Object.create() to inherit object
         */

        ZEUS.DEBUG.log("2. ** Use Object.create() to inherit object **");

        var copyBook = ObjUtil.inherit(book);
        copyBook.title = "Thinking In Java";
        copyBook.author.firstname = "Bruce";
        copyBook.author.lastname = "Eckle";
        copyBook["publish date"] = "2005-09-01";

        ZEUS.DEBUG.log("Original Object:");
        ZEUS.DEBUG.log("Title: " + book.title);
        ZEUS.DEBUG.log("Author: " + book.author.firstname + " " + book.author.lastname);
        ZEUS.DEBUG.log("Publish Date: " + book["publish date"]);

        ZEUS.DEBUG.log("Copied Object:");
        ZEUS.DEBUG.log("Title: " + copyBook.title);
        ZEUS.DEBUG.log("Author: " + copyBook.author.firstname + " " + copyBook.author.lastname);
        ZEUS.DEBUG.log("Publish Date: " + copyBook["publish date"]);

        ZEUS.DEBUG.log("<br />");

        /*
            Delete Property
         */
        ZEUS.DEBUG.log("3. ** Delete Property **");
        delete book.title;
        delete book.author.firstname;
        delete book.author.lastname;
        delete book["publish date"];
        ZEUS.DEBUG.log("Title: " + book.title);
        ZEUS.DEBUG.log("Publish Date: " + book["publish date"]);
        ZEUS.DEBUG.log("Author: " + copyBook.author.firstname + " " + copyBook.author.lastname);

        ZEUS.DEBUG.log("<br />");
    }

</script>

<h2>Object Create</h2>
<br />
<h3>Path: @ViewBag.Path</h3>
<br />
<h3>Extended JS: /JsLib/G_Core.js</h3>
<br />
<h3>See the result on console</h3>
<br />
